//
//  BLTableBarViewController.m
//  百思不得姐
//
//  Created by hbl on 16/3/14.
//  Copyright © 2016年 hbl. All rights reserved.
//

#import "BLTableBarViewController.h"
#import "BLNavigatonViewController.h"
#import "BLMeTableViewController.h"
#import "BLEssenceTableViewController.h"
#import "BLFriendTrendsTableViewController.h"
#import "BLNewTableViewController.h"
#import "BLTabBar.h"
#import "BLToTopWindow.h"
@interface BLTableBarViewController ()

@end

@implementation BLTableBarViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupChild];
    [self setupAppearance];
    
    
}

- (void)setupAppearance
{
    [self setValue:[[BLTabBar alloc]init] forKey:@"tabBar"];
    UITabBarItem *item = [UITabBarItem appearance];
    NSMutableDictionary *attr = [NSMutableDictionary dictionary];
    attr[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    [item setTitleTextAttributes:attr forState:UIControlStateSelected];
    
}

- (void)setupChild
{
    BLEssenceTableViewController *essence = [[BLEssenceTableViewController alloc]init];
    [self setupChildViewController:essence title:@"精华" image:@"tabBar_essence_icon" selImage:@"tabBar_essence_click_icon"];
    
    BLNewTableViewController *new = [[BLNewTableViewController alloc]init];
    [self setupChildViewController:new title:@"新帖" image:@"tabBar_new_icon" selImage:@"tabBar_new_click_icon"];
    
    BLFriendTrendsTableViewController *friendTrends = [[BLFriendTrendsTableViewController alloc]init];
    [self setupChildViewController:friendTrends title:@"关注" image:@"tabBar_friendTrends_icon" selImage:@"tabBar_friendTrends_click_icon"];
    
    BLMeTableViewController *me = [[BLMeTableViewController alloc]init];
    [self setupChildViewController:me title:@"我" image:@"tabBar_me_icon" selImage:@"tabBar_me_click_icon"];
}

- (void)setupChildViewController:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selImage:(NSString *)selImage
{
    BLNavigatonViewController *nav = [[BLNavigatonViewController alloc]initWithRootViewController:vc];
    nav.title = title;
    vc.title = title;
    nav.tabBarItem.image = [UIImage imageNamed:image];
    nav.tabBarItem.selectedImage = [UIImage imageNamed:selImage];
    [self addChildViewController:nav];
}

@end
